package pl.polsl.mmm.projectcomm.programs;

import pl.polsl.mmm.projectcomm.R;

import android.content.Context;
import static android.opengl.GLES20.*;
public class ColorShaderProgram extends ShaderProgram{
	private final int uMatrixLocation;
	private final int uColorLocation;
	private final int aPositionLocation;
	
	public ColorShaderProgram(Context context) {
		super(context, R.raw.simple_vertex_shader, R.raw.simple_fragment_shader);
		
		uMatrixLocation = glGetUniformLocation(program, U_MATRIX);
		
		aPositionLocation = glGetAttribLocation(program, A_POSITION);
		
		uColorLocation = glGetUniformLocation(program, U_COLOR);

        glValidateProgram(program);
	}
	
	public void setMatrix(float[] matrix) {
		glUniformMatrix4fv(uMatrixLocation, 1, false, matrix, 0);
	}

    public void setColor(float r, float g, float b) {
        glUniform4f(uColorLocation, r, g, b, 1f);
    }
	
	public int getPositionAttributeLocation() {
		return aPositionLocation;
	}
	
}
